package com.zx.notification.common.enums;

import lombok.Getter;

/**
 * <p>
 * description: 渠道类型枚举定义 <br>
 * create: 2025-10-15 16:20
 * </p>
 *
 * @author zhou  xun
 */
@Getter
public enum ChannelTypeEnum {
    INBOX(ChannelTypeEnum.INBOX_CODE, "站内信"),
    WEBSOCKET(ChannelTypeEnum.WEBSOCKET_CODE, "实时推送"),
    SMS(ChannelTypeEnum.SMS_CODE, "短信通知"),
    EMAIL(ChannelTypeEnum.EMAIL_CODE, "邮件通知"),
    APP_PUSH(ChannelTypeEnum.APP_PUSH_CODE, "APP推送"),
    WECHAT(ChannelTypeEnum.WECHAT_CODE, "微信推送");

    public static final String INBOX_CODE = "INBOX";
    public static final String WEBSOCKET_CODE = "WEBSOCKET";
    public static final String SMS_CODE = "SMS";
    public static final String EMAIL_CODE = "EMAIL";
    public static final String APP_PUSH_CODE = "APP_PUSH";
    public static final String WECHAT_CODE = "WECHAT";

    private final String code;
    private final String desc;

    ChannelTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据编码获取枚举值
     *
     * @param code 编码
     * @return 枚举值
     */
    public static ChannelTypeEnum getEnumByCode(String code) {
        for (ChannelTypeEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 根据名称获取枚举值
     *
     * @param desc 描述
     * @return 枚举值
     */
    public static ChannelTypeEnum getEnumByDesc(String desc) {
        for (ChannelTypeEnum value : values()) {
            if (value.desc.equals(desc)) {
                return value;
            }
        }
        return null;
    }

}